<template>
	<view class="container">

		<view class="list">
			<view class="name">收货人</view>
			<input @blur="getName" class="input" type="text" placeholder="名字">
		</view>

		<view class="list">
			<view class="name">手机号码</view>
			<input @blur="getPhone" class="input" type="text" placeholder="手机号码">
		</view>

		<!-- 	<view class="list">
			<view class="name">所在地区</view>
			<view class="input">省 市 区</view>
		</view>

		<view class="list">
			<view class="name">详细地址</view>
			<input class="input" type="text" placeholder="街道/小区楼栋/乡村名称">
		</view> -->
		<view class="list">
			<view class="name">所在地区</view>
			<input @blur="getAddress" class="input" type="text" placeholder="省/市/区/街道/小区楼栋/乡村名称">
		</view>

		<view class="bottom">
			<view class="button" @click="addAdress">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				setdata: {
					addressName: "",
					addressPhone: "",
					addressLocation: "",
					token: ''
				}
			}
		},
		onShow() {
			var bs = uni.getStorageSync('UserInformation')
			this.token = bs.usertoken
		},
		methods: {
			getAddress(e) {
				this.setdata.addressLocation = e.detail.value
			},
			getPhone(e) {
				this.setdata.addressPhone = e.detail.value
			},
			getName(e) {
				this.setdata.addressName = e.detail.value
			},
			addAdress() {
				this.requestfs({
					url: '/mall/customer/address/addOrUpdateAddress',
					data: this.setdata,
					method: "POST",
					Authorization: this.token,
				}).then(res => {
					if (res.data.msg == "success") {
						uni.showToast({
							icon: 'success',
							title: '地址添加成功'
						})
						uni.navigateBack(1)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 750rpx;
		padding-top: 20rpx;

		.list {
			width: 705rpx;
			margin: 0 auto;
			height: 100rpx;
			line-height: 100rpx;
			display: flex;
			font-size: 28rpx;
			margin-bottom: 20rpx;

			.input {
				background: #f6f6f6;
				width: 78%;
				height: 80rpx;
				margin-top: 10rpx;
				border-radius: 15rpx;
				padding-left: 15rpx;
				color: #808080;
				line-height: 80rpx;
			}

			.name {
				width: 22%;
				font-weight: bold;
			}
		}

		.bottom {
			width: 100%;
			text-align: center;
			margin-top: 80rpx;

			.button {
				width: 90%;
				margin: 0 auto;
				background-image: linear-gradient(to right, rgba(237, 127, 48, 0.7), rgba(236, 96, 45, 1));
				height: 80rpx;
				line-height: 80rpx;
				color: #ffffff;
				border-radius: 50rpx;
			}
		}
	}
</style>
